home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6887 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.mira.net.au!news
  2. From: davidw@werple.net.au (David White)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Is there a standard for * and & placement style?
  5. Date: 20 Feb 1996 21:21:34 +1100
  6. Organization: Werple Internet, Melbourne
  7. Message-ID: <4gc7be$gta@werple.net.au>
  8. References: <3128BD31.4AF8@wildfire.com>
  9. NNTP-Posting-Host: werple.mira.net.au
  10.  
  11. Stonewall Ballard <stoney@wildfire.com> writes:
  12.  
  13. >I'm trying to find out whether there is a "standard" for the 
  14. >placement of * and &. A survey of C++ texts shows that most use
  15.  
  16. >Form 1
  17. >  int&  foo;
  18. >  int*  foo;
  19.  
  20. >while some use
  21.  
  22. >Form 2
  23. >  int&  foo;
  24. >  int  *foo;
  25.  
  26. >and nobody uses (although I've seen this a lot in code)
  27.  
  28. >Form 3
  29. >  int  &foo;
  30. >  int  *foo;
  31.  
  32. >The ARM and the latest C++ working paper both use form 1. The 
  33. >most well-known user of form 2 is Scott Meyers in his Effective 
  34. >C++ books. People I work with use form 3.
  35.  
  36. >Imagine that you were given a class framework to use and extend. 
  37. >Would you expect that the placement of & and * follow one of the 
  38. >above schemes? Do you perceive that there is a standard for the 
  39. >placement of * and &? If so, what is it?
  40.  
  41. >Please reply by email to stoney@wildfire.com
  42.  
  43. >I will summarize the results to the group.
  44.  
  45. There doesn't seem to be a standard. My preference is 'int *foo', because 
  46. that's the way the compiler sees it. For example, what is the type of 'q' 
  47. here? int* p, q;
  48. Also, there are cases when you have no choice, e.g., int (*foo)();
  49.  
  50. David White
  51. davidw@werple.mira.net.au
  52.  
  53.